package com.enjoyread.api.controller;

import com.enjoyread.common.config.SystemConfig;
import com.enjoyread.common.utils.RUtils;
import com.enjoyread.common.vo.R;
import com.enjoyread.core.dto.UserDetailUpdateDto;
import com.enjoyread.core.service.intf.UserDetailService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @author: JC
 * @time: 2021/10/27 17:18
 * @description:
 */
@RestController
@RequestMapping("/api/userdetail")
@Api(value = "用户信息模块",tags = "用户信息模块")
public class UserDetailController {
    @Autowired
    private UserDetailService service;


    @PostMapping("update")
    public R update(@RequestBody UserDetailUpdateDto dto, HttpServletRequest request){
        return service.update(request.getIntHeader(SystemConfig.HEADER_TOKEN_UID),dto);
    }

    @GetMapping("detail")
    public R detail(HttpServletRequest request){
        return RUtils.ok(service.queryByUid(request.getIntHeader(SystemConfig.HEADER_TOKEN_UID)));
    }
}
